{extend name="admin@public/form"}

{block name="form"}
<fieldset class="layui-elem-field">
    <legend>生成Api文档</legend>
    <form class="layui-field-box layui-form layui-form-pane">
        <div class="layui-form-item">
            <label class="layui-form-label">api文档名称</label>
            <div class="layui-input-inline">
                <input type="text" name="row[apidoc_name]" id="apidoc_name" placeholder="请输入api文档名称" autocomplete="off" class="layui-input" value="{$apidoc_name}" />
            </div>
            <div class="layui-form-mid layui-word-aux">生成的Api文档的文件名，例：默认使用api，则会在根目录下生成api.html文件</div>
        </div>
        <div class="form-footer">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*">立即生成</button>
                    <a class="layui-btn layui-btn-sm layui-btn-danger" href="javascript:void(0);" onclick="showApi();">立即查看</a>
                </div>
            </div>
        </div>
    </form>
</fieldset>
<fieldset class="layui-elem-field">
    <legend>Api注释规范举例 - application/api/controller/Test.php</legend>
<pre class="layui-code">
namespace app\api\controller;

use controller\Api;

/**
 * 测试分组
 */
class Test extends Api{
    /**
     * @ApiTitle    (测试名称)
     * @ApiSummary  (测试描述信息)
     * @ApiMethod   (POST)
     * @ApiRoute    (/api/test/index)
     * @ApiParams   (name="id", type="integer", required=true, description="会员ID")
     * @ApiParams   (name="name", type="string", required=true, description="用户名")
     * @ApiParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="返回成功")
     * @ApiReturnParams   (name="data", type="object", sample="{'user_id':'int','user_name':'string','profile':{'email':'string','age':'integer'}}", description="扩展数据返回")
     * @ApiReturn
({
    'code':'1',
    'msg':'返回成功'
})
     */
    public function index()
    {
        $this->success("返回成功", $this->request->request());
    }
}
    </pre>
</fieldset>
{/block}

{block name="javascript"}
<script type="text/javascript">
    function showApi(){
        window.open('/' + $('#apidoc_name').val() + '.html');
    }
</script>
{/block}